from enum import Enum, IntEnum
from typing import Final


# 系统级常量
class Environment(str, Enum):
    """环境类型"""

    DEV = "dev"
    TEST = "test"
    PROD = "prod"


class BoolEnum(IntEnum):
    """布尔类型枚举"""

    TRUE = 1
    FALSE = 0


class APIResourceMethodEnum(str, Enum):
    """API资源方法枚举"""

    GET = "get"
    POST = "post"
    PUT = "put"
    PATCH = "patch"
    DELETE = "delete"


class GenderType(IntEnum):
    """性别类型"""

    MAN = 1
    WOMAN = 0
    NO = 2  # 不详


class OrgTypeEnum(IntEnum):
    COMPANY = 1  # 公司
    DEPARTMENT = 2  # 部门
    GROUP = 3  # 组
    TEAM = 4  # 团队


class RoleType(str, Enum):
    """角色类型"""

    SUPER_ADMIN = "super_admin"  # 超级管理员
    ADMIN = "admin"  # 管理员
    USER = "user"  # 普通用户
    GUEST = "guest"  # 访客


class TaskStatus(IntEnum):
    PAUSED = 0
    ACTIVE = 1


class ExecutionStatus(IntEnum):
    RUNNING = 1
    SUCCESS = 2
    FAILED = 3
    TIMEOUT = 4
    CANCELLED = 5


class ChangeType(IntEnum):
    CREATE = 1  # 创建任务
    UPDATE = 2  # 更新任务
    DELETE = 3  # 删除任务
    PAUSE = 4  # 暂停任务
    RESUME = 5  # 恢复任务


class ExecutorType(IntEnum):
    """执行类型"""

    SCRIPT = 1  # 执行脚本
    MODULE = 2  # 执行模块


class TriggerType(IntEnum):
    CRON = 0  # 定时触发器
    INTERVAL = 1  # 循环触发器
    DELAY = 2  # 延时触发器


class OrderType(IntEnum):
    ASC = 1
    DESC = 2


class PointSourceType(IntEnum):
    """积分来源类型"""

    SIGN_IN = 1  # 签到
    TASK = 2  # 任务
    ADMIN = 3  # 管理员操作
    OTHER = 99  # 其他


class BalanceSourceType(IntEnum):
    """余额来源类型"""

    RECHARGE = 1  # 充值
    CONSUME = 2  # 消费
    REFUND = 3  # 退款
    ADMIN = 4  # 管理员操作
    OTHER = 99  # 其他


class StorageProviderEnum(IntEnum):
    """存储供应商类型"""

    LOCAL = 1  # 本地存储
    ALIYUN_OSS = 2  # 阿里云OSS
    AWS_S3 = 3  # AWS S3
    TENCENT_COS = 4  # 腾讯云COS


class FileStatusEnum(IntEnum):
    """文件状态枚举"""

    PENDING = 1  # 待处理
    UPLOADING = 2  # 上传中
    COMPLETED = 3  # 已完成
    FAILED = 4  # 失败


# 权限相关常量
DEFAULT_ROLE: Final[str] = RoleType.GUEST
ADMIN_ROLES: Final[tuple] = (RoleType.SUPER_ADMIN, RoleType.ADMIN)

PUBLIC_PATHS: Final[tuple] = ("/api/v1/auth/login", "/api/v1/auth/register", "/api/v1/openapi.json", "/docs")


# 文件上传相关常量
MAX_FILE_SIZE: Final[int] = 100 * 1024 * 1024  # 100MB
CHUNK_SIZE: Final[int] = 5 * 1024 * 1024  # 5MB 分片上传大小
MAX_BATCH_SIZE: Final[int] = 10  # 批量操作最大数量限制

# 允许的文件类型
ALLOWED_FILE_TYPES = {
    "image/jpeg",
    "image/png",
    "image/gif",
    "image/webp",
    "application/pdf",
    "application/msword",
    "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
    "application/vnd.ms-excel",
    "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
    "application/vnd.ms-powerpoint",
    "application/vnd.openxmlformats-officedocument.presentationml.presentation",
    "text/plain",
    "application/zip",
    "application/x-rar-compressed",
    "application/x-7z-compressed",
}


# 存储供应商类型
class StorageProviderType(IntEnum):
    """存储供应商类型"""

    LOCAL = 1  # 本地存储
    ALIYUN = 2  # 阿里云OSS
    AWS_S3 = 3  # AWS S3
    TENCENT_COS = 4  # 腾讯云COS


class FileStatusEnum(IntEnum):
    """文件状态枚举"""

    PENDING = 1  # 待处理
    UPLOADING = 2  # 上传中
    COMPLETED = 3  # 已完成
    FAILED = 4  # 失败


# 权限相关常量
class PermissionEnum(IntEnum):
    """权限枚举"""

    FILE_UPLOAD = 1001  # 文件上传
    FILE_DOWNLOAD = 1002  # 文件下载
    FILE_DELETE = 1003  # 文件删除
    FILE_LIST = 1004  # 文件列表
    PROVIDER_MANAGE = 1005  # 供应��管理
